<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
    同步回调
    异步回调
    */

    /* 同步回调 */

    [1, 2, 3].forEach(item => {
      console.log(item)
    })
    console.log('forEach()之后')
    
    new Promise((resolve, reject) => {  // 执行器  excutor
      console.log('excutor...')

      // 执行异步任务

      // 如果成功了, 调用resolve ==> 变为成功的, 并指定value    => response

      // 如果失败了, 调用reject  => 变为失败的, 并指定reason  => error

    })
    console.log('new Promise之后')

    /* 异步回调  需要放到对应的队列中, 再取出执行 */
    // setTimeout(() => { 
    //   console.log('执行timout回调')
    // }, 0)
    // console.log('setTimeout()之后')

    // Promise.resolve(1).then(() => {// 异步回调
    //   console.log('promise成功的回调')
    // })
    // console.log('.then之后')
  </script>

</body>
</html>